<?php

/**
 * This is the model class for table "alert".
 *
 * The followings are the available columns in table 'alert':
 * @property string $alert_id
 * @property string $name
 * @property string $desc
 * @property integer $days
 * @property integer $level
 * @property double $amout
 * @property string $alert_type
 * @property string $alert_text
 */
class Alert extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Alert the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'alert';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('days, level', 'numerical', 'integerOnly'=>true),
			array('amout', 'numerical'),
			array('name, desc, alert_text', 'length', 'max'=>512),
			array('alert_type', 'length', 'max'=>255),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('alert_id, name, desc, days, level, amout, alert_type, alert_text', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'alert_id' => 'Alert',
			'name' => 'Name',
			'desc' => 'Desc',
			'days' => 'Days',
			'level' => 'Level',
			'amout' => 'Amout',
			'alert_type' => 'Alert Type',
			'alert_text' => 'Alert Text',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('alert_id',$this->alert_id,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('desc',$this->desc,true);
		$criteria->compare('days',$this->days);
		$criteria->compare('level',$this->level);
		$criteria->compare('amout',$this->amout);
		$criteria->compare('alert_type',$this->alert_type,true);
		$criteria->compare('alert_text',$this->alert_text,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}